﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
using YArchitech.LIB;

namespace YArchitech.Controls
{
	public partial class HYBaseForm : System.Windows.Forms.Form
	{
		public HYBaseForm()
		{
			this.InitializeComponent();
			//base.Icon = Resource.YArchitechIcon;
			base.Location = new Point(0, 0);
		}

		protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
		{
			int num = 256;
			int num2 = 260;
			if ((msg.Msg == num | msg.Msg == num2) && keyData == Keys.Escape)
			{
				base.Close();
			}
			return false;
		}

		private void HYBaseForm_Load(object sender, EventArgs e)
		{
			if (!base.DesignMode)
			{
				XMLUserSetting xmluserSetting = new XMLUserSetting();
				Dictionary<string, string> formLocationSetting = xmluserSetting.GetFormLocationSetting("FormLocation" + base.GetType().Name);
				int x = Convert.ToInt32(xmluserSetting.GetValueFromDic("X", "0", formLocationSetting));
				int y = Convert.ToInt32(xmluserSetting.GetValueFromDic("Y", "0", formLocationSetting));
				base.Location = new Point(x, y);
			}
		}

		private void HYBaseForm_FormClosed(object sender, FormClosedEventArgs e)
		{
			XMLUserSetting xmluserSetting = new XMLUserSetting();
			Dictionary<string, string> dictionary = new Dictionary<string, string>();
			dictionary.Add("X", base.Location.X.ToString());
			dictionary.Add("Y", base.Location.Y.ToString());
			xmluserSetting.WriteFormLocationSetting("FormLocation" + base.GetType().Name, dictionary);
		}
	}
}
